package com.nbcio.modules.erp.cart.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nbcio.modules.erp.cart.entity.CartItems;
import com.nbcio.modules.erp.cart.service.CartItemsService;
import com.nbcio.modules.erp.cart.mapper.CartItemsMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 31955
* @description 针对表【cart_items】的数据库操作Service实现
* @createDate 2024-04-10 14:42:42
*/
@Service
public class CartItemsServiceImpl extends ServiceImpl<CartItemsMapper, CartItems>
    implements CartItemsService{

    /**
     * 根据购物车id查询购物车明细
     * @param mainId
     * @return
     */
    @Override
    public List<CartItems> queryByMainId(String mainId) {

        LambdaQueryWrapper<CartItems> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CartItems::getCartId,mainId);
        List<CartItems> cartItemsList = list(wrapper);
        if (CollectionUtil.isNotEmpty(cartItemsList)){
            return cartItemsList;
        }
        return new ArrayList<>();
    }
}




